#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
@file_name: running_cpu_bound_code_in_debug_mode.py
@date: 2025-07-28 17:24
@author: Falling Snow
@desc: 在debug模式下运行协程
"""

import asyncio

from util import async_timed


@async_timed()
async def cpu_bound_work() -> int:
    counter = 0
    for i in range(10_000_000):
        counter += 1

    return counter


async def main():
    # 更改时间阈值, 设置为250毫秒
    asyncio.get_running_loop().slow_callback_duration = .7

    task_1 = asyncio.create_task(cpu_bound_work())
    await task_1


if __name__ == '__main__':
    asyncio.run(main(), debug=True)
